<%@include file="/WEB-INF/pages/commons/commons.jsp"%>

<c:set var="selectedTab" value="Blogs" scope="request"/>
<fmt:message var="title" key="blog_view_entry_details.jsp.title" scope="request"/>
<stripes:layout-render name="${_themePath}/basic-layout-without-navbar.jsp" _title="${title}">

        <stripes:layout-component name="_topNav">
            <H1>Blog Management</H1>
            <UL class="gc-topnav-tabs">
                <LI>&nbsp;</LI>
            </UL>
        </stripes:layout-component>


        <stripes:layout-component name="_head">
        <jsecurity:hasPermission name="blog:viewBlogEntries:${actionBean.blogEntry.blog.id}">
        <script type="text/javascript">
            $(document).ready(function() {

                $("#preview").click(function(){
                    //var form = this.form;
                    //var params = $(form).serializeArray();
                    //params.push({name:'blogEntry',value:''})

                    var params = new Array();
                    var previewContent = $("#previewContent").val();
                    params.push({name:'previewContent', value:previewContent});
                    params.push({name:'blog', value:'${actionBean.blogEntry.blog.id}'});

                    $.post(
                        '<stripes:url beanclass="foo.bar.blog.web.action.registered.BlogsProfileActionBean" event="previewBlogEntry"/>',
                        params,
                        function(data){
                            $("#display").hide();
                            $("#display").html("<form><h2>Preview [<a onclick='$(\"#display\").hide();' href='#'>close</a>]</h2><span class='radeox'>"+data+"</span><p/><p/><p/></form>");
                            $("#display").fadeIn();
                        });
                    return false;
                });


                $("#commandHelp").click(function(){
                    window.open('<stripes:url beanclass="foo.bar.blog.web.action.general.RenderEngineCommandHelpActionBean" />',
                            'commandHelp', 'status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=500,width=500');
                    return false;
                });

                $("#backToBlogEntriesListing").click(function() {
                    <stripes:url var="url" beanclass="foo.bar.blog.web.action.registered.BlogsProfileActionBean" event="viewBlogEntries">
                        <stripes:param name="blog" value="${actionBean.blogEntry.blog.id}"/>
                    </stripes:url>
                    window.location = '<c:out value="${url}" escapeXml="false"/>';
                });
            });
        </script>
        </jsecurity:hasPermission>
    </stripes:layout-component>



    <stripes:layout-component name="_content">

        <stripes:layout-component name="_topNav">
            <H1>Blog Management</H1>
            <UL class="gc-topnav-tabs">
                <LI>&nbsp;</LI>
            </UL>
        </stripes:layout-component>

        <div id="display">
        </div>

        <h2>Entry Details</h2>
        <jsecurity:lacksPermission name="blog:viewBlogEntries:${actionBean.blogEntry.blog.id}">
            No "blog:viewBlogEntries:${actionBean.blogEntry.blog.id}" permission
        </jsecurity:lacksPermission>
        <jsecurity:hasPermission name="blog:viewBlogEntries:${actionBean.blogEntry.blog.id}">
        <div id="form">
        <stripes:form beanclass="foo.bar.blog.web.action.registered.BlogsProfileActionBean">
        <table width="100%">
            <input type="hidden" name="blogEntry" value="${actionBean.blogEntry.id}"/>
            <tr>
                <td><stripes:label name="blogEntry.name"/></td>
                <td><stripes:text name="blogEntry.name" disabled="true"/></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.description"/></td>
                <td><stripes:text name="blogEntry.description" disabled="true"/></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.state"/></td>
                <td><stripes:text name="blogEntry.state" disabled="true"/></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.tag"/></td>
                <td><stripes:text name="blogEntry.tag.name" disabled="true" /></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.content"/></td>
                <td><stripes:textarea id="previewContent" name="blogEntry.content" disabled="true" style="width:100%;" rows="10"/></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.allowComments"/></td>
                <td><stripes:checkbox name="blogEntry.allowComments" disabled="true" /></td>
            </tr>
            <tr>
                <td><stripes:label name="blogEntry.commentExpiryDate"/></td>
                <td><stripes:text name="blogEntry.commentExpiryDate" disabled="true" /></td>
            </tr>
            <tr>
                <td colspan="2">
                    <stripes:button id="preview" name="preview"><fmt:message key="blog_view_entry_details.jsp.preview"/></stripes:button>
                    <stripes:button id="commandHelp" name="commandHelp"><fmt:message key="blog_view_entry_details.jsp.commandHelp"/></stripes:button>
                    <stripes:button id="backToBlogEntriesListing" name="backToBlogEntriesListing"><fmt:message key="blog_view_entry_details.jsp.backToBlogEntriesListing"/></stripes:button>
                </td>
            </tr>
        </table>
        </stripes:form>
        </div>
        </jsecurity:hasPermission>
    </stripes:layout-component>
</stripes:layout-render>

